﻿using MiData;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace VolunteerManager.Model
{
    /// <summary>
    /// 系统配置表
    /// </summary>
    public class Config : MiActiveRecord
    {
        public static string PhotoRoot{get;set;}

        [Column(Name = "Key")]
        public string Key { get; set; }

        [Column(Name = "Value")]
        public string Value { get; set; }

        public override string TableName
        {
            get { return "Config";  }
        }

        public  static bool CheckPass(string p)
        {
            
            Config config = new Config().Find("Key", "Password") as Config;
            if (config.Value == Tool.MD5Hash(p))
            {
                return true;
            }
            return false;
        }

        internal static bool ChnagePass(string p)
        {
            Config config = new Config().Find("Key", "Password") as Config;
            config.Value = Tool.MD5Hash(p);
            return config.Save() > 0;
        }
    }
}
